<template>
  <div>
    <mu-popup position="bottom" popupClass="demo-popup-bottom" :open="bottomPopup" @close="close()">
      <mu-appbar title="Boss推荐">
        <mu-flat-button slot="right" label="关闭" color="white" @click="close()"/>
      </mu-appbar>
      <mu-content-block>
        <h3>你推荐的书是 <span>《{{bookMes.name}}》</span></h3>
        <h3 >选择推荐用户</h3><span>{{usersName}}</span>
        <div style="margin-left: 18px;display: inline">
          <mu-float-button icon="add" mini class="demo-float-button" @click="chooseDep"/>
        </div>
        <h3>说点什么</h3>
        <mu-text-field hintText="不允许超过100个字符" :errorText="multiLineInputErrorText" v-model="recMes"
                       @textOverflow="handleMultiLineOverflow" multiLine :rows="3" :rowsMax="6" :maxLength="100"
                       fullWidth="" icon="comment"/>
        <br/>
        <mu-raised-button label="Ding出去" class="clickButton" @click="postDing" primary/>
      </mu-content-block>
    </mu-popup>
  </div>
</template>
<script>
  import dingweb from '../util/dd'
  export default {
    name: 'dingPopUp',
    props: {
      book: Array
    },
    data () {
      return {
        bottomPopup: false,
        value: '',
        recMes: '',
        bookMes: this.book,
        usersId: [],
        usersName: [],
      }
    },
    methods: {
      open () {
        this.bottomPopup = true;
      },
      close () {
        this.bottomPopup = false
      },
      handleMultiLineOverflow (isOverflow) {
        this.multiLineInputErrorText = isOverflow ? '超过啦！！！！' : ''
      },
      chooseDep(){
        dingweb.getAuth().then(function (response) {
          dingweb.getDepartments().then(function (result) {
              alert(result.users[0].name);
            var userIdList ;
            var userNameList ;
  /*          for (let i = 0; i < result.selectedCount; i++) {
              userIdList.push(result.users[i].emplId);
              userNameList.push(result.users[i].name);
            }
            this.$set(this, 'usersId', userIdList);
            this.$set(this, 'usersName', userNameList);*/
          })
        })
      },
      postDing(){
        const self = this;
        alert(self.users);
        var user = self.users;
        dingweb.POSTDing(users);
      }
    },
  }
</script>
<style scoped>
  .demo-popup-bottom {
    width: 100%;
    max-width: 375px;
  }
</style>
